package com.ogawa.a7517.widget;

import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.widget.FrameLayout;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;

import com.ogawa.a7517.R;

public class PointView extends FrameLayout {
    private LinearLayout llPoint0, llPoint1, llPoint2, llPoint3, llPoint4, llPoint5, llPoint6, llPoint7, llPoint8, llPoint9, llPoint10, llPoint11, llPoint12, llPoint13, llPoint14, llPoint15, llPoint16;

    public PointView(@NonNull Context context) {
        super(context);
        init(context);
    }

    public PointView(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public PointView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    public PointView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        init(context);
    }

    private void init(Context context) {
        LayoutInflater.from(context).inflate(R.layout.layout_point_view, this);
        llPoint0 = findViewById(R.id.point_0);
        llPoint1 = findViewById(R.id.point_1);
        llPoint2 = findViewById(R.id.point_2);
        llPoint3 = findViewById(R.id.point_3);
        llPoint4 = findViewById(R.id.point_4);
        llPoint5 = findViewById(R.id.point_5);
        llPoint6 = findViewById(R.id.point_6);
        llPoint7 = findViewById(R.id.point_7);
        llPoint8 = findViewById(R.id.point_8);
        llPoint9 = findViewById(R.id.point_9);
        llPoint10 = findViewById(R.id.point_10);
        llPoint11 = findViewById(R.id.point_11);
        llPoint12 = findViewById(R.id.point_12);
        llPoint13 = findViewById(R.id.point_13);
        llPoint14 = findViewById(R.id.point_14);
        llPoint15 = findViewById(R.id.point_15);
        llPoint16 = findViewById(R.id.point_16);
    }

    public void setPointVis(int pos) {
        llPoint0.setVisibility(pos == 0 ? VISIBLE : INVISIBLE);
        llPoint1.setVisibility(pos == 1 ? VISIBLE : INVISIBLE);
        llPoint2.setVisibility(pos == 2 ? VISIBLE : INVISIBLE);
        llPoint3.setVisibility(pos == 3 ? VISIBLE : INVISIBLE);
        llPoint4.setVisibility(pos == 4 ? VISIBLE : INVISIBLE);
        llPoint5.setVisibility(pos == 5 ? VISIBLE : INVISIBLE);
        llPoint6.setVisibility(pos == 6 ? VISIBLE : INVISIBLE);
        llPoint7.setVisibility(pos == 7 ? VISIBLE : INVISIBLE);
        llPoint8.setVisibility(pos == 8 ? VISIBLE : INVISIBLE);
        llPoint9.setVisibility(pos == 9 ? VISIBLE : INVISIBLE);
        llPoint10.setVisibility(pos == 10 ? VISIBLE : INVISIBLE);
        llPoint11.setVisibility(pos == 11 ? VISIBLE : INVISIBLE);
        llPoint12.setVisibility(pos == 12 ? VISIBLE : INVISIBLE);
        llPoint13.setVisibility(pos == 13 ? VISIBLE : INVISIBLE);
        llPoint14.setVisibility(pos == 14 ? VISIBLE : INVISIBLE);
        llPoint15.setVisibility(pos == 15 ? VISIBLE : INVISIBLE);
        llPoint16.setVisibility(pos == 16 ? VISIBLE : INVISIBLE);
    }
}
